<template>
  <el-dialog
    custom-class="subDialog"
    :title="title"
    v-model="dialogPopVisible"
    :width="width"
    :before-close="onBeforeClose"
    :center="true"
    v-bind="option"
  >
    <div><component :is="comps"></component></div>
  </el-dialog>
</template>

<script>
import { ElDialog } from "element-plus";
export default {
  data() {
    return {
      dialogPopVisible: true,
    };
  },
  components: { ElDialog },
  props: {
    title: {
      type: String,
      default: "",
    },
    width: {
      type: String,
      default: "550px",
    },
    option: {
      type: Object,
      default: () => {},
    },
    remove: {
      type: Function,
    },
    comps: {
      require: false,
    },
  },
  methods: {
    onBeforeClose(done) {
      done();
    },
  },
  watch: {
    dialogPopVisible(value) {
      if (!value) {
        this.remove();
      }
    },
  },
};
</script>

<style lang="scss">
.subDialog {
  &.el-dialog {
    z-index: 99;
    background-color: #ffffff;
    margin-top: 20% !important;
  }
  .el-dialog__header {
    width: 100%;
    height: 50px;
    line-height: 50px;
    box-sizing: border-box;
    padding: 0 25px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  }
  .el-dialog__headerbtn {
    font-size: 20px;
    width: 40px;
    height: 40px;
  }
  .el-dialog__title {
    font-size: 18px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.85);
  }
  .el-dialog__body {
    box-sizing: border-box;
    padding: 20px 25px;
  }
  .el-dialog__footer {
    text-align: right;
    height: 60px;
    line-height: 60px;
    padding: 0;
    margin-right: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
  }
}
</style>